package com.tbit.main.service.impl;

import com.tbit.main.constant.DaoParamConstant;
import com.tbit.main.dao.core.MachineLoseDao;
import com.tbit.main.pojo.MachineLose;
import com.tbit.main.service.MachineLoseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author LMY
 * @create 2021-05-11 17:13
 */
@Service("machineLoseService")
public class MachineLoseServiceImpl implements MachineLoseService {

    @Autowired
    private MachineLoseDao machineLoseDao;

    @Override
    public MachineLose getAccountIdAndUserCode(Integer accountId, String userCode) {
        Map<String, Object> map = new HashMap<>();
        map.put(DaoParamConstant.accountId, accountId);
        map.put("userCode", userCode);
        return machineLoseDao.getAccountIdAndUserCode(map);
    }

    @Override
    public void insert(MachineLose machineLose) {
        machineLoseDao.insert(machineLose);
    }

    @Override
    public void del(String userCode) {
        machineLoseDao.del(userCode);
    }

    @Override
    public List<MachineLose> getByAccountId(Integer accountId, Integer pageNO, Integer rowCount) {
        Map<String, Object> map = new HashMap<>();
        map.put(DaoParamConstant.accountId, accountId);
        map.put("start", (pageNO - 1) * rowCount);
        map.put("rowCount", rowCount);
        return machineLoseDao.getByAccountId(map);
    }

    @Override
    public Integer getByAccountIdCount(Integer accountId) {
        return machineLoseDao.getByAccountIdCount(accountId);
    }

    @Override
    public List<MachineLose> getUseMachine() {
        return machineLoseDao.getUseMachine();
    }


}
